package com.ruoyi.comments.controller;

import com.ruoyi.comments.domain.StudentEvaluationWithFeedback;
import com.ruoyi.comments.service.IStudentEvaluation;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.ruoyi.common.utils.PageUtils.startPage;

/**
 * 学生评价老师审核
 * @author 尹欣雨
 * @verdion 520
 * 19:24
 */
@Anonymous
@RestController
@RequestMapping("/StudentEvaluation")
public class StudentEvaluationController{

    @Autowired
    private IStudentEvaluation studentEvaluation;
    /**
     * 根据学生学号和评价学期获取评价信息
     *
     * @param studentId
     * @param CommitTime
     * @return
     */
    @GetMapping(value = "/getStudentEvaluation/{studentId}/{CommitTime}")
    public AjaxResult getStudentEvaluation(@PathVariable("studentId") String studentId, @PathVariable("CommitTime") String CommitTime){
        StudentEvaluationWithFeedback studentEvaluationWithFeedback = studentEvaluation.selectOneEvaluation(studentId,CommitTime);
        return AjaxResult.success(studentEvaluationWithFeedback);
    }

    /**
     * 获取全部信息
     * @return
     */
    @GetMapping(value = "/getStudentEvaluationList")
    public AjaxResult getStudentEvaluationList(){
        startPage();
        return AjaxResult.success(studentEvaluation.selectListEvaluationList());
    }

    /**
     *更新操作
     */
    @Anonymous
    @PutMapping("/updateStudentEvaluation")
    public AjaxResult updateStudentEvaluation(@RequestBody StudentEvaluationWithFeedback studentEvaluationWithFeedback){
        return AjaxResult.success(studentEvaluation.updateStudentEvaluation(studentEvaluationWithFeedback));
    }

    /**
     * 插入数据
     */
    @Anonymous
    @PostMapping("/insertStudentEvaluation")
    public AjaxResult insertStudentEvaluation(@RequestBody StudentEvaluationWithFeedback studentEvaluationWithFeedback){
        return AjaxResult.success(studentEvaluation.insertStudentEvaluation(studentEvaluationWithFeedback));
    }
}
